home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Plotting / aa_Intel_Only / Gnuplot / GnuplotSource / TicCell.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.4 KB  |  100 lines

  1. /*
  2.  *  Copyright (C) 1993  Robert Davis
  3.  *
  4.  *  This program is free software; you can redistribute it and/or
  5.  *  modify it under the terms of Version 2, or any later version, of 
  6.  *  the GNU General Public License as published by the Free Software 
  7.  *  Foundation.
  8.  */
  9.  
  10. static char RCSId[]="$Id: TicCell.m,v 1.4 1993/05/04 16:23:06 davis Exp $";
  11.  
  12.  
  13. #import <appkit/Font.h>
  14. #import <appkit/Text.h>        /* NXTextFontInfo()        */
  15. #import <dpsclient/wraps.h>
  16. #import <strings.h>
  17.  
  18. #import "TicCell.h"
  19. #import "TicObject.h"
  20.  
  21. #define VALUE_COLUMN_END 95.0
  22. #define STRING_COLUMN_START 100.0
  23. #define DIGITS_ACCURACY 5
  24.  
  25.  
  26. @implementation TicCell
  27.  
  28. - drawInside:(const NXRect *)cellFrame inView:controlView
  29. {
  30.     float    stringWidth;
  31.     NXRect    rectArray[2];
  32.     char    valueString[100];
  33.  
  34.     sprintf (valueString, "%.*f", DIGITS_ACCURACY, [subObject doubleValue]);
  35.  
  36.     /*
  37.      *  Find width of the string, which depends on the font, which
  38.      *  depends on whether we're printing or drawing.
  39.      */
  40.  
  41.     if (NXDrawingStatus == NX_DRAWING)
  42.     stringWidth = [[[support screenFont] set] getWidthOf:valueString];
  43.     else
  44.     stringWidth = [[support set] getWidthOf:valueString];
  45.  
  46.     PSsetgray(cFlags1.highlighted ? NX_WHITE : NX_LTGRAY);     /* Erase cell */
  47.     NXRectFill(cellFrame);
  48.  
  49.  
  50.     PSsetgray(cFlags1.disabled? NX_DKGRAY : NX_BLACK);
  51.  
  52.     /*
  53.      *  TicCells draw both the double value and the string value in
  54.      *  the cell.  Here's the string value ("contents"):
  55.      */
  56.  
  57.     PSmoveto(NX_X(cellFrame) + STRING_COLUMN_START,
  58.              NX_Y(cellFrame) + lineHeight - descender);
  59.     PSshow(contents);
  60.  
  61.     /*  ... and the double value:  */
  62.  
  63.     PSmoveto(NX_X(cellFrame) + VALUE_COLUMN_END - stringWidth,
  64.          NX_Y(cellFrame) + lineHeight - descender);
  65.     PSshow(valueString);
  66.  
  67.  
  68.     /*  Draw the two dark gray lines above and below the cell.  */
  69.  
  70.     PSsetgray(NX_DKGRAY);
  71.     if (cFlags1.highlighted) {
  72.     /*
  73.      *  Draw 1-pixel tall rectangles instead of lines (this is
  74.      *  faster than PSmoveto(); PSlineto()).
  75.      */
  76.     NXSetRect(&(rectArray[0]), NX_X(cellFrame), NX_Y(cellFrame),
  77.           NX_WIDTH(cellFrame), 1.0);
  78.     NXSetRect(&(rectArray[1]), NX_X(cellFrame), NX_MAXY(cellFrame) - 1.0,
  79.           NX_WIDTH(cellFrame), 1.0);
  80.  
  81.     /*
  82.      * Using NXRectFillList is faster than separate calls to
  83.      * NXRectFill.
  84.      */
  85.     NXRectFillList(rectArray, 2);
  86.     }
  87.  
  88.     return self;
  89. }
  90.  
  91.  
  92. // Shuts up the compiler about unused RCSId
  93. - (const char *) rcsid
  94. {
  95.     return RCSId;
  96. }
  97.  
  98.  
  99. @end
  100.